function pw() {
    return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
}
;
function mouseX(evt) {
    return evt.clientX ? evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : evt.pageX;
}
function mouseY(evt) {
    return evt.clientY ? evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : evt.pageY
}
function popUp(evt, oi) {
    if (document.getElementById) {
        var wp = pw();
        var dm = document.getElementById(oi);
        var wNoScroll = dm.offsetWidth;
        var wScroll = dm.offsetWidth;
        var scrollDist = (wNoScroll - wScroll);
        var ds = dm.style;
        var st = ds.visibility;
        var ew = 0;
        if (dm.offsetWidth) {
            ew = dm.offsetWidth;
        } else if (dm.clip) {
            ew = dm.clip.width;
        }
        var index0 = oi.substring(4, 5);

        if (index0 == 'K') {
                    ew = ew * 3;
        }

        if (index0 > 'M') {
            ew = ew * 4;
        }
        if (index0 > 'N') {
            ew = ew + 144;
        }
        var eh = 0;
        if (dm.offsetHeight) {
            eh = dm.offsetHeight;
        } else if (dm.clip) {
            eh = dm.clip.height;
        }
        if (st == "visible" || st == "show") {
            ds.visibility = "hidden";
        } else {
            var lv = mouseX(evt) - (ew / 4);// + f_scrollLeft();
            if (index0 >= 'K') {
                lv = mouseX(evt) + ew;
            } else {
                if (lv + ew > 800) {
                    lv -= ew / 2;
                }
            }
            var tv = mouseY(evt) + (10);// + f_scrollTop();
            /*if (lv < 2){
             lv = 2;
             }*/


            lv += 'px';
            tv += 'px';
            ds.left = lv;
            ds.top = tv;
            ds.visibility = "visible";
            //alert("ew" + ew + " " + dm + "left/top:" + ds.left + "/" + ds.top);
            eventManager.fireStatusMessageEvent({ text: "id:" + oi + " mouseX:" + mouseX(evt) + " extra-width " + ew + " left/top:" + ds.left + "/" + ds.top + " scrollD:" + scrollDist, level: "info" });
        }
    }
}

function f_clientWidth() {
    return f_filterResults(
            window.innerWidth ? window.innerWidth : 0,
            document.documentElement ? document.documentElement.clientWidth : 0,
            document.body ? document.body.clientWidth : 0
            );
}
function f_clientHeight() {
    return f_filterResults(
            window.innerHeight ? window.innerHeight : 0,
            document.documentElement ? document.documentElement.clientHeight : 0,
            document.body ? document.body.clientHeight : 0
            );
}
function f_scrollLeft() {
    return f_filterResults(
            window.pageXOffset ? window.pageXOffset : 0,
            document.documentElement ? document.documentElement.scrollLeft : 0,
            document.body ? document.body.scrollLeft : 0
            );
}
function f_scrollTop() {
    return f_filterResults(
            window.pageYOffset ? window.pageYOffset : 0,
            document.documentElement ? document.documentElement.scrollTop : 0,
            document.body ? document.body.scrollTop : 0
            );
}
function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
